
 /**  
 * Project Name:zhonghecrm  
 * File Name:SysStudentAttrServiceImpl.java  
 * Package Name:com.crm.service.impl  
 * Date:2016年11月10日下午3:08:50   
 *  
*/  
  
package com.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.dao.SysStudentAttrMapper;
import com.crm.model.SysStudentAttr;
import com.crm.service.SysStudentAttrService;
import com.crm.util.UUIDUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

/**  
 * ClassName:SysStudentAttrServiceImpl <br/>  
 * Function: TODO ADD FUNCTION. <br/>  
 * Reason:   TODO ADD REASON. <br/>  
 * Date:     2016年11月10日 下午3:08:50 <br/>  
 * @author   hanlinxiu  
 * @version    
 * @since    JDK 1.8  
 * @see        
 */
@Service
public class SysStudentAttrServiceImpl extends BaseServiceImpl<SysStudentAttr> implements SysStudentAttrService{
	@Autowired
	SysStudentAttrMapper sysStudentAttrMapper;
	
	@Override
	public int insert(SysStudentAttr record) {
		Integer attrType = record.getAttrType();
		int code = 0;
		String codeNumber = sysStudentAttrMapper.selectNumber(attrType);
		int codeNumbers = Integer.parseInt(codeNumber);
		code = codeNumbers+1;
		String uuid = UUIDUtil.getUUID();
		record.setStudentAttrId(uuid);
		record.setCode(code);
		return super.insert(record);
	}
	
	@Override
	public List<SysStudentAttr> selectAll(Page<SysStudentAttr> page,SysStudentAttr t) {
		
		PageHelper.startPage(page.getPageNum(), page.getPageSize(), "code asc");
		
		List<SysStudentAttr> list = sysStudentAttrMapper.selectAllByWhere(t);
		
		return list;
	}
}
  
